﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace TlToolBase
{
    public class StringHelp
    {
        public static string ToCamelCase(string input)
        {
            // 将非字母数字字符替换为空格
            string pattern = @"[^a-zA-Z0-9]+";
            string replaced = Regex.Replace(input, pattern, " ");

            // 将字符串分割为单词数组
            string[] words = replaced.Split(' ');

            // 将第一个单词的首字母小写，其余单词的首字母大写
            for (int i = 0; i < words.Length; i++)
            {
                if (i == 0)
                {
                    words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
                }
                else
                {
                    words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
                }
            }

            // 将单词数组连接成一个字符串
            return string.Join("", words);
        }
    }
}
